package com.itheima;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo2 {
    public static void main(String[] args) {
        HashMap<String, String> hm = new HashMap<>();
        hm.put("姓名", "张三");
        hm.put("年龄", "20");
        hm.put("性别", "男");
        hm.put("地址", "北京海淀区");
        hm.put("专业", "java");
        hm.put("地址", "北京顺义区");

        Set<String> set = hm.keySet();

        if (hm.containsKey("地址")){
            String newAddress = "北京顺义区";
            String address = hm.put("地址",newAddress);
        }

        for (String key : set) {
            String value = hm.get(key);
            System.out.println(key + "------" + value);
        }
        System.out.println("---------------------");

        Set<Map.Entry<String, String>> entries = hm.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + "--------" + value);
        }
    }
}
